<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <link rel="stylesheet" href="./css/bootstrap.css">
    <style>
        .form-control {
            width: 250px;
        }
    </style>
</head>

<body>
    <div id="content"></div>
    <template id="tem1">
        <div class="container">
            <h2>添加页面</h2>
            <div class="form-group">
                <label for="">username</label>
                <input type="text" class="form-control" placeholder="username" v-model="user.username">
            </div>
            <div class="form-group">
                <label for="">age</label>
                <input type="text" class="form-control" placeholder="age" v-model="user.age">
            </div>
            <button class="btn btn-success" @click="add()">添加</button>
            <button class="btn btn-info">
                <a href="./index.html">返回</a>
            </button>
        </div>
    </template>
    <script src="./js/jquery.min.js"></script>
    <script src="./js/vue.min.js"></script>
    <script>
        var vm = new Vue({
            el: '#content',
            template: '#tem1',
            data: function () {
                return {
                    user: {
                        username: '',
                        age: ''
                    }
                }
            },
            methods: {
                add: function () {
                    $.post('/Users/add', this.user).done(function () {
                        location.href = './index.html'
                    })
                }
            }
        })
    </script>
</body>

</html>